/**
 * 工具函数
 */
console.log("工具函数");
//引入iconfont字体图标
require("../../fonts/iconfont.css")
/**
 * 验证手机号码
*/
function phoneCheck(num) {
    return /^1[3-9]\d{9}$/.test(num)
}
/**
 * 验证密码
*/
function passwordCheck(pwd){
    return  /^[a-zA-Z]\w{5,17}$/.test(pwd);
}
// 弹出框的样式
function popupBox(icon="",content=""){
    let body=document.querySelector("body")
    let msgbox=document.createElement("div")
    msgbox.className="msgbox";
    msgbox.style=`
    width:200px;
    height:200px;
    border-radius:12px;
    position:fixed;
    top:50%;
    left:50%;
    transform:translate(-50%,-50%);
    text-align:center;
    background-color:#4c4c4c;
    `
    msgbox.innerHTML=`
    <div><i class="iconfont icon-${icon} "></i></div>
    
    <p class="mt20">${content}</p>
    `
    body.appendChild(msgbox);
    //关闭弹窗
    let timeId=setInterval(()=>{
        msgbox.style.display = "none";
        clearInterval(timeId)
    },2000)
    document.addEventListener("click",function(){
        msgbox.style.display = "none";
    })
}
//端口号

 const portNum= "http://139.9.177.51:3701"


/**
 * 挂载(暴露)window对象身上
*/
window.$util = {
    phoneCheck,
    passwordCheck,
    popupBox,
    portNum,
}